package com.example.demo.scheduledtask;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.demo.mapper.PoMpsinfoMapper;
import com.example.demo.mapper.WmsErpUpDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * wms拉取erp数据任务
 */
@Component
@Slf4j
@DS("wms")
public class WmsErpUpDataScheduledTask {

    @Autowired
    WmsErpUpDataMapper wmsErpUpDataMapper;

    @Scheduled(cron = "0 0/10 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsRrpUpQtck() {
        //拉取其他出库数据
        wmsErpUpDataMapper.wmsErpUpQtck();
    }

    @Scheduled(cron = "0 0/8 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsStMoveSync() {
        //生产调拨 wms_st_move_sync
        wmsErpUpDataMapper.wmsStMoveSync();
    }

    @Scheduled(cron = "0 0/5 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsDeleteStMoveSync() {
        //生产调拨 wms_st_move_sync
        wmsErpUpDataMapper.wmsDeleteStMoveSync();
    }

    @Scheduled(cron = "0 0/12 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpWmsStMove() {
        //外部调拨 wms_erp_wms_st_move
        wmsErpUpDataMapper.wmsErpWmsStMove();
    }

    @Scheduled(cron = "0 0/55 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpUpBaCpinfo() {
        //同步物料信息 wms_erp_up_ba_cpinfo
        wmsErpUpDataMapper.wmsErpUpBaCpinfo();
    }

    @Scheduled(cron = "0 0/8 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpUpShipment() {
        //更新销售出货通知单 wms_erp_up_shipment
        wmsErpUpDataMapper.wmsErpUpShipment();
    }

    @Scheduled(cron = "0 0/50 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpUpBaEmployeeinfo() {
        //更新erp员工信息 wms_erp_up_ba_employeeinfo
        wmsErpUpDataMapper.wmsErpUpBaEmployeeinfo();
    }

    @Scheduled(cron = "0 0/13 * * * ?")
    //@Async(value = "taskExecutor")
    public void wmsErpSaReturn() {
//        exec wms_erp_sa_return
        //销售退货单 wms_erp_up_shipment
        wmsErpUpDataMapper.wmsErpSaReturn();
    }
}
